package com.youfang.sixthmedia.ui.weibo;

import com.gzit.common.async.LoadingCallback;

import android.app.Activity;
import android.os.AsyncTask;

public abstract class WeiboActivity extends Activity {

	protected abstract void init();

	protected abstract void onOAuthCallback(boolean ok);

	protected abstract void gotoOAuthActivity();

	protected abstract boolean sendWeibo(String content, String picPath);

	// weibo async task...
	public abstract class WeiboTask extends AsyncTask<String, Integer, Boolean> {

		LoadingCallback loading;

		public WeiboTask(Activity ctx) {
			loading = new LoadingCallback.DefaultLoadingCallback(ctx);

		}

		abstract boolean doTask(String... params);

		abstract void callback(boolean result);

		@Override
		protected void onPreExecute() {

			super.onPreExecute();
			loading.showLoading();
		}

		@Override
		protected void onPostExecute(Boolean result) {
			super.onPostExecute(result);
			loading.hideLoading();
			callback(result);

		}

		@Override
		protected Boolean doInBackground(String... params) {

			return doTask(params);
		}

	}

}
